package org.cash.cashrule;

import java.math.BigDecimal;

//促销 满减 购物满100减10块
public class CashReturn extends CashSuper {
    //满减条件
    private Double returnCondition;
    //减数额
    private Double returnCash;

    public CashReturn(Double returnCondition, Double returnCash) {
        this.returnCondition = returnCondition;
        this.returnCash = returnCash;
    }

    @Override
    public BigDecimal acceptCash(BigDecimal money) {
        if (money.doubleValue() >= this.returnCondition) {
            return money.subtract(new BigDecimal(Math.floor((money.divide(new BigDecimal(returnCondition.toString()))).doubleValue())).multiply(new BigDecimal(returnCash.toString())));//每100即减10
//            return money - ReturnCash;//满足100即可一次性减10
        }
        return money;
    }
}
